package com.study.leetcode;

public class Solution_104 {
    private int maxDepth = 0;
    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }
        maxDepth = 0;
        maxDepth(root, 0);
        return maxDepth;
    }

    public void maxDepth(TreeNode node, int depth) {
        if (node == null) {
            return;
        }
        depth = depth + 1;
        maxDepth = Math.max(maxDepth, depth);
        maxDepth(node.left, depth);
        maxDepth(node.right, depth);
    }
}
